import _regeneratorRuntime from "@babel/runtime/regenerator";
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
var _excluded = ["organizationId"];

/*
 * service - 库位
 * @date: 2018-8-10

 */
import request from 'utils/request';
import { CPAAS_PLATFORM } from 'utils/config';
import { parseParameters, filterNullValueObject } from 'utils/utils';
/**
 *查询库房
 * @async
 * @function queryLibPosition
 * @param {?string} params.locationCode 库房编码
 * @param {?string} params.locationName 库房名称
 * @param {?string} params.ouName 业务实体
 * @param {Number} [params.page = 0] - 数据页码
 * @param {Number} [params.size = 10] - 分页大小
 * @returns {object} fetch Promise
 */

export function queryLibPosition(_x) {
  return _queryLibPosition.apply(this, arguments);
}
/**
 *保存库位数据
 * @async
 * @function saveLibraryPosition
 * @param {object} params
 * @param {!string} params.organizationId - 租户Id
 * @param {!Array<Object>} params.payloadData - 待保存的数据信息
 * @returns {object} fetch Promise
 */

function _queryLibPosition() {
  _queryLibPosition = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(params) {
    var organizationId, otherParams, param;
    return _regeneratorRuntime.wrap(function _callee$(_context) {
      while (1) {
        switch (_context.prev = _context.next) {
          case 0:
            organizationId = params.organizationId, otherParams = _objectWithoutProperties(params, _excluded);
            param = filterNullValueObject(parseParameters(otherParams));
            return _context.abrupt("return", request("".concat(CPAAS_PLATFORM, "/v1/").concat(organizationId, "/locations"), {
              method: 'GET',
              query: param
            }));

          case 3:
          case "end":
            return _context.stop();
        }
      }
    }, _callee);
  }));
  return _queryLibPosition.apply(this, arguments);
}

export function saveLibraryPosition(_x2) {
  return _saveLibraryPosition.apply(this, arguments);
}

function _saveLibraryPosition() {
  _saveLibraryPosition = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(params) {
    var payloadData, organizationId;
    return _regeneratorRuntime.wrap(function _callee2$(_context2) {
      while (1) {
        switch (_context2.prev = _context2.next) {
          case 0:
            payloadData = params.payloadData, organizationId = params.organizationId;
            return _context2.abrupt("return", request("".concat(CPAAS_PLATFORM, "/v1/").concat(organizationId, "/locations/batch-save"), {
              method: 'POST',
              body: payloadData
            }));

          case 2:
          case "end":
            return _context2.stop();
        }
      }
    }, _callee2);
  }));
  return _saveLibraryPosition.apply(this, arguments);
}